package com.spring.aop.interceptor;

import com.spring.aop.Advisor;
import com.spring.aop.InterceptorChain;

import java.lang.reflect.Method;

public class AfterInterceptor extends Interceptor {
	public AfterInterceptor(Advisor advisor) {
		super(advisor);
	}
	
	
	@Override
	public Object invoke(InterceptorChain chain, Object targetObject, Method targetMethod, Object[] args) throws Throwable {
		try {
			return chain.proceed(targetObject, targetMethod, args);
		} finally {
			// 后置通知在这里，无论是否出现异常都会执行
			advisor.after();
		}
	}
}
